using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.DirectX;

namespace SteeringBehaviors
{
    public class MovingObject : BaseObject
    {
        #region PRIVATE MEMBERS

        Vector3 velocity;

        #endregion

        #region PROPERTIES

        /// <summary>
        /// Velocity vector.  Determines speed and direction for movement.
        /// </summary>
        public Vector3 Velocity
        {
            get { return velocity; }
            set
            {
                if (Single.IsNaN(value.X))
                    throw new Exception();
                if (Single.IsNaN(value.Y))
                    throw new Exception();
                velocity = value;
            }
        }

        #endregion

        #region CONSTRUCTORS

        public MovingObject()
        {
            Type = "MovingObject";
            Velocity = new Vector3();
        }

        #endregion

        #region INTERFACE METHODS

        /// <summary>
        /// Updates this object's position based on change in time and velocity vector.
        /// </summary>
        /// <param name="_delta">seconds since last update</param>
        public virtual void Update(float _delta)
        {
            SetHeadingFromVector3(Velocity);
            Vector3 movement = new Vector3();
            movement = Velocity;
            movement.Scale(_delta);
            this.Position += movement;
        }

        #endregion
    }
}
